package com.fjec.market.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.fjec.common.protocol.JsonResult;
import com.fjec.market.entity.InfoDeliveryCompany;
import com.fjec.market.mapper.InfoDeliveryCompanyMapper;
import com.fjec.market.service.IInfoDeliveryCompanyService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 047.快递公司表 服务实现类
 * </p>
 *
 * @author admin
 * @since 2020-09-21
 */
@Service
public class InfoDeliveryCompanyServiceImpl extends ServiceImpl<InfoDeliveryCompanyMapper, InfoDeliveryCompany> implements IInfoDeliveryCompanyService {

    @Resource
    private InfoDeliveryCompanyMapper mapper;

    @Override
    public JsonResult getDeliveryCompanyList() {
        QueryWrapper<InfoDeliveryCompany> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("delFlag", 0)
                .eq("Vaild", 1)
                .orderByAsc("sort");
        List<InfoDeliveryCompany> entityList = mapper.selectList(queryWrapper);
        List<Map<String, Object>> resultList = new ArrayList<>();
        for (InfoDeliveryCompany entity : entityList) {
            Map<String, Object> map = new HashMap<>();
            map.put("id", entity.getId());
            map.put("name", entity.getCompName());
            resultList.add(map);
        }
        return JsonResult.success()
                .data(resultList)
                .build();
    }
}
